// Copyright 2022 Huawei Cloud Computing Technology Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef CLOUDAPPENGINE_CAEPARAMSTORAGE_H
#define CLOUDAPPENGINE_CAEPARAMSTORAGE_H

#include <string>
#include "../cae_CPHMediaEngine/CPHMediaEngine.h"
#include "../cae_common/CaeLogConfig.h"

class CaeParamStorage {
public:
    static CaeParamStorage &GetInstance();
    CaeParamStorage(const CaeParamStorage &) = delete;
    CaeParamStorage &operator = (const CaeParamStorage &) = delete;

    ~CaeParamStorage();

    void ClearAllParams() noexcept;

    void SetIp(std::string ip);
    std::string GetIp();

    void SetPort(std::string port);
    std::string GetPort();

    void SetUserId(std::string userId);
    std::string GetUserId();

    void SetTicket(std::string ticket);
    std::string GetTicket();

    void SetAuthTs(std::string authTs);
    std::string GetAuthTs();

    void SetVerifyData(std::string verifyData);
    std::string GetVerifyData();

    void SetEncyptedData(std::string encyptedData);
    std::string GetEncyptedData();

    void SetAesIv(std::string aesIv);
    std::string GetAesIv();

    void SetSdkVersion(std::string sdkVersion);
    std::string GetSdkVersion();

    void SetProtolcolVersion(std::string protocolVersion);
    std::string GetProtocolVersion();

    void SetSessionId(std::string sessionId);
    std::string GetSessionId();

    void SetBackgroundTimeout(std::string timeout);
    std::string GetBackgroundTimeout();

    void SetAvailablePlayTime(std::string availablePlayTime);
    std::string GetAvailablePlayTime();

    void SetAesKey(std::string aeskey);
    std::string GetAeskey();

    void SetStartTime(time_t startTime);
    time_t GetStartTime();

    void SetTouchTimeout(std::string touchTimeout);
    std::string GetTouchTimeout();

    void SetMaxDisconnectDuration(std::string &disconnectTimes);
    std::string GetMaxDisconnectDuration();

protected:
    CaeParamStorage();

    void InitClientParams() noexcept;

    void InitSessionParams() noexcept;

private:
    static CaeParamStorage *instance;

    std::string m_ip;
    std::string m_port;
    std::string m_userId;
    std::string m_ticket;
    std::string m_authTs;
    std::string m_verifyData;
    std::string m_encryptedData;
    std::string m_aesIv;
    std::string m_sdkVersion;
    std::string m_protocolVersion;
    std::string m_sessionId;
    std::string m_backgroundTimeout;
    std::string m_availablePlaytime;
    std::string m_touchTimeout;

    std::string m_maxDisconnectDuration;
    std::string m_aesKey;
    time_t m_startTime;
};
#endif // CLOUDAPPENGINE_CAEPARAMSTORAGE_H